package com._21cn._front.cms.api;

import com._21cn.framework.http.HttpRequestInfo;
import com._21cn.framework.utils.StringUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/12/10.
 */
@Controller
@RequestMapping({"/api"})
public class AdApiController {

    private static Map<String, String> urlMap = new HashMap<String, String>();

    static {
//        urlMap.put("tcXaaNydgOwg4huJ","https://toutiao.eastday.com?qid=qid11108");
//        urlMap.put("ecd381d7f4f26e2d","https://m.hoteastday.com/?qid=z00260");
//        urlMap.put("7fbd79ec09e84338","http://feed.114la.com/zx.html");
//        urlMap.put("14e87290552a2b04","http://d.cjpy.com/?huitt");
//        urlMap.put("014e3067d1ba303d","http://47.98.56.225:8020/link/821a1f7c-363f-4db9-a1e9-a197ac1235ef");
//        urlMap.put("f75f7ba8b80e3840","https://3g.jun4.com/16/?cs01");
//        urlMap.put("39f4c4a6f1353fc2","https://m.xilu.com/site/htt1/index.html");
//        urlMap.put("df34426b49125908","http://m.yuexinwen.cn/bd/news/home?media=267&submedia=392");
//        urlMap.put("06649c3bda15554b","https://m.uczzd.cn/webview/newslist?app=sxm9-iflow&zzd_from=sxm9-iflow&uc_param_str=dndsfrvesvntnwpfgi&uc_biz_str=S%253Acustom%257CC%253Azzd_list&is_default_wolong=1&is_hide_top=1&is_hide_bottom=1");
//        urlMap.put("cee6fa4ae7567394","http://newspool.huolea.com/waifangsspsu/s1/index.html?appKey=1823d00424104f8");
//        urlMap.put("a0b923820dcc509a","http://3g.jun4.com/114/?ys01");
//        urlMap.put("a0b923820dcd509b","https://cpu.baidu.com/1022/b5fef569/i?pu=1&promotion_media_channel=33017");
//        urlMap.put("bb92dfe38d50fe9b","http://attbd.newsyin.com");
//        urlMap.put("b92dfe38ddcfe9cc","http://456.idping.com/archives/category/headlines");
//        urlMap.put("aaaxxxdddfff2233","http://news.xsmpa.cn/index.html?code=C851");
//        urlMap.put("aaaxxxdddfff4444","https://m.hoteastday.com/media/?qid=z00298");
//        urlMap.put("bbbxxxdddfff5555","http://newspool.techenergize.com/waifangsspgrlm/s1/index.html?appKey=a6d884ce86eb150");
//        urlMap.put("bbbxxxdddfff6666","https://5g.baizhan.net/98/skip.html");
//        urlMap.put("bbbxxxdddfff7777","http://m.ifeedad.com/url/u062601");
//        urlMap.put("bbbxxxdddfff8888","http://m.vrezhou.cn/bd/news/home?media=425&submedia=583");
//        urlMap.put("bbbxxxdddfff9999","http://m.ifeedad.com/url/u062603");
//        urlMap.put("bbbxxxdddfff1111","http://newspool.huolea.com/waifangsspsu/s1/index.html?appKey=ca26d81064d5df5");
//        urlMap.put("bbbxxxdddfff0000","https://www.xjtt.top/3/");
//        urlMap.put("aaaxxxdddfff0000","http://newspool.aichuangzuo.cn/waifangsspgrlm/s1/index.html?appKey=bab0fea9bcc9a76");
//        urlMap.put("aaaxxxdddfff1111","http://m.lifetimes.cn/1/dlhh/77/list_77_1_10.htm");
//        urlMap.put("aaaxxxdddfff2222","http://newspool.zhangxinzhixun.com/waifangsspgrlm/s1/index.html?appKey=9bab7f997290281");
//        urlMap.put("aaaxxxdddfff3333","http://newspool.palmssp.com/waifangsspgrlm/s1/index.html?appKey=dfc805c924293c5");
//        urlMap.put("cccxxxdddfff4444","http://m.qiaoliba.com/xj/");
//        urlMap.put("cccxxxdddfff5555","http://newspool.palmcontent.com/waifangsspgg/s1/index.html?appKey=ca26d81064d5df5");
//        urlMap.put("cccxxxdddfff6666","https://cpu.baidu.com/1022/a595e1c2/i?pu=1&promotion_media_channel=34847");
//        urlMap.put("cccxxxdddfff7777","http://47.98.56.225:8020/link/0e3fb8c4-bdb6-4f40-b58b-bc0e58837f83");
//        urlMap.put("cccxxxdddfff8888","http://news.zizhengjiankang.com/jc5File/webview/detail_list.html");
//        urlMap.put("cccxxxdddfff9999","https://bdtest.todaycity.com/?ch=todaycity");
//        urlMap.put("dddxxxdddfff0000","http://toutiao.eastday.com/?qid=qid11244");
//        urlMap.put("dddxxxdddfff1111","http://newspool.palmssp.com/waifangsspgrlm/s1/index.html?appKey=34d1dfa734603e4");
//        urlMap.put("dddxxxdddfff2222","http://47.98.56.225:8020/link/1717a900-3412-4f7e-a9cd-5e469ac36e78");
//        urlMap.put("dddxxxdddfff3333","http://newspool.zhangxinzhixun.com/waifangsspgrlm/s1/index.html?appKey=9bab7f997290281");
//        urlMap.put("dddxxxdddfff4444","https://m.hoteastday.com/?qid=z00260");
//        urlMap.put("dddxxxdddfff5555","https://www.werewolf.mobi/kkz/channel?ref=544");
//        urlMap.put("dddxxxdddfff6666","https://api.ammobi.cn/redirect/26");
//        urlMap.put("dddxxxdddfff7777","http://w.mgtoutiao.com/index.html?s=1030&cid=gaoxiao");
//        urlMap.put("dddxxxdddfff8888","http://newspool.zhangxinzhixun.com/waifangsspgrlm/s1/index.html?appKey=d12acaf75bd0003");
//        urlMap.put("dddxxxdddfff9999","http://newspool.worldwidetech.cn/waifangsspsu/s1/index.html?appKey=cadc2be9c306d43");
//        urlMap.put("eeexxxdddfff0000","http://link.qukanzixun.com/link/3c9cc176-4ec4-4903-99d9-4e025ea851b9");
//        urlMap.put("eeexxxdddfff1111","https://toutiao.eastday.com/?qid=qid11242");
//        urlMap.put("eeexxxdddfff2222","http://www.biulie.com/?pid=500101");
//        urlMap.put("eeexxxdddfff3333","https://about.usee123.com/land/junshidao.htm");
//        urlMap.put("eeexxxdddfff4444","http://c25rbd.aenun.com");
//        urlMap.put("eeexxxdddfff5555","http://link.qukanzixun.com/link/c96f6e6d-f2e8-4daf-830d-ef2bc997b4df");
//        urlMap.put("eeexxxdddfff6666","https://news.cnxk.com/page/list/5d3952a36f1f3c3b97e7d125.html");
//        urlMap.put("eeexxxdddfff7777","http://news.111g.com/h5/zxapp1.html");
//        urlMap.put("eeexxxdddfff8888","https://cpu.baidu.com/1001/c1bfaaab?scid=38437");
//        urlMap.put("eeexxxdddfff9999","https://mqid1028.51dstt.com");
//        urlMap.put("fffxxxdddfff0000","https://mkandian.mop.com/?mq=mp009");
//        urlMap.put("fffxxxdddfff1111","https://cpu.baidu.com/1021/b2b2ac4a?scid=39204");
//        urlMap.put("fffxxxdddfff2222","http://link.qukanzixun.com/link/3d5ae465-b3a9-4265-bb02-e776a8e47511");
//        urlMap.put("fffxxxdddfff3333","https://mread.huabian.com/api/sc/hot");
//        urlMap.put("fffxxxdddfff4444","http://news.hzsic.cn/index.html?code=C881&category=%E5%A8%B1%E4%B9%90");
//        urlMap.put("fffxxxdddfff5555","http://m.palmssp.com?q=5f6c5378");
//        urlMap.put("fffxxxdddfff6666","https://4g.baizhan.net/skip/skip_mgtt.html");
//        urlMap.put("fffxxxdddfff7777","http://quredian.jcgame.net/?id=10008");
//        urlMap.put("fffxxxdddfff8888","https://cpu.baidu.com/wap/1022/275230367/i?pu=1&promotion_media_channel=33660");
//        urlMap.put("fffxxxdddfff9999","http://wap.yoohour.com/cd290842/");
//        urlMap.put("gggxxxdddfff0000","http://m.lifetimes.cn/1/dlhh/77/list_77_1_10.htm");
//        urlMap.put("gggxxxdddfff1111","https://api.lieqi12.com/web/htq/hot.html");
//        urlMap.put("gggxxxdddfff2222","http://toutll.allibook.com/app/reader/726584?bookstore=3&t=10&tk=hakjoebj2019080601&channel=hakjoebj");
//        urlMap.put("gggxxxdddfff3333","https://st.9adl.com/V3a2Aj");
//        urlMap.put("gggxxxdddfff4444","http://lobby.qiyu3.com/template/index.html?app_id=gzjd1&v=5#/news");
//        urlMap.put("gggxxxdddfff5555","http://121.42.243.177/r/?rno=3390");
//        urlMap.put("gggxxxdddfff6666","http://qd195616.yoohour.com");
//        urlMap.put("gggxxxdddfff7777","http://lobby.qiyu3.com/template/index.html?app_id=wap&v=5#/news");
//        urlMap.put("gggxxxdddfff8888","http://t.channel.45xie.com/manhua/home.html?appid=05B133683CDD17C3BE225985B01F4FBD");
//        urlMap.put("gggxxxdddfff9999","https://mcp.9idudu.com/mf/list?aid=3acfgyk9");
//        urlMap.put("hhhxxxdddfff0000","http://m.worldwidetech.cn?q=397366dc");
        urlMap.put("hhhxxxdddfff1111","https://toutiao.eastday.com?qid=qid11108");
        urlMap.put("hhhxxxdddfff2222","http://lobby.qiyu3.com/template/index.html?app_id=gzjd1&v=5#/news");
        urlMap.put("hhhxxxdddfff3333","http://www.playwonderful.net/?cid=505923");
        urlMap.put("hhhxxxdddfff4444","com.songheng.eastnews://wireless:80/wakeuphome?wakeUpType=60");
        urlMap.put("hhhxxxdddfff5555","http://ayquc.ymgan.com/normal/");
        urlMap.put("hhhxxxdddfff6666","https://toutiao.eastday.com?qid=qid11108");
        urlMap.put("hhhxxxdddfff7777","https://7.xmwn.net/index.php?FVEYGKtj");
        urlMap.put("hhhxxxdddfff8888","http://www.wijslgws.com/archives/1067");
        urlMap.put("hhhxxxdddfff9999","http://www.quanmamaon.com/t/applandingpage/qmmapp_0yuangou.aspx?key=liu5");
        urlMap.put("iiixxxdddfff0000","http://t.wykz.com/s/Cgpg8QKH7A");
        urlMap.put("iiixxxdddfff1111","http://jmug.tvshuju.com/bc/");
        urlMap.put("iiixxxdddfff2222","https://7.xmwn.net/index.php?FVEYGKtj");
        urlMap.put("iiixxxdddfff3333","http://rt185.3oclock.mobi/rt.html");
        urlMap.put("iiixxxdddfff4444","https://engine.lvehaisen.com/index/activity?appKey=xYpxbAmnfmgNdEjFZP4J7kNkPiW&adslotId=308108");
        urlMap.put("iiixxxdddfff5555","https://vku.youku.com/live/ilproom?id=8023704&refer=chaoliushengdian_operation.qrwang_00002226_7000_bqyE3u_19101700");
        urlMap.put("iiixxxdddfff6666","https://render.alipay.com/p/f/jfxb4alj/pages/receive-redpacket/index.html?__webview_options__=ttb%253Dauto&partnerId=1001&sceneCode=KF_DYW02&shareChannel=QRCode&shareUserId=2088131876115982&sharedUserId=");
        urlMap.put("iiixxxdddfff7777","http://ym.tmomf.cn/news/XLAALL.html");
        urlMap.put("iiixxxdddfff8888","https://liyanmobi.com/news?c=hhmt");
        urlMap.put("iiixxxdddfff9999","http://lobby.qiyu3.com/template/index.html?app_id=gzjd1&v=5#/news");
        urlMap.put("jjjxxxdddfff0000","http://www.zhiyingzhurui.com/qds=10103");
        urlMap.put("jjjxxxdddfff1111","http://m.nxipp.com/");
        urlMap.put("jjjxxxdddfff2222","http://ddxw.allibook.com/app/reader/726589?bookStore=3&t=10&tk=kveay2019102901&channel=kveay&timer=2&gctrlh5=1");
        urlMap.put("jjjxxxdddfff3333","http://www.qiaoliba.com/hd/20/a.html?v=2");
        urlMap.put("jjjxxxdddfff4444","https://game.hdbaichuan.cn/show.htm?app_key=11956ba780734980");
        urlMap.put("jjjxxxdddfff5555","https://act.occrab.cn/channel/index?cid=1605&appKey=70dcd249d4bad0d6e63c54b7cb4c5f89");
        urlMap.put("jjjxxxdddfff6666","http://www.qiaoliba.com/hd/bc88b8b204501cf7.html");
    }
    @RequestMapping({"/url"})
    public void monitorData(HttpServletRequest request, HttpServletResponse response, ModelMap model) {
        HttpRequestInfo reqInfo = new HttpRequestInfo(request);

        String key = reqInfo.getParameter("key","");
        try {
            String url = urlMap.get(key);
            if(StringUtil.isEmpty(url)){
                response.sendRedirect("http://m.qiaoliba.com");
                return;
            }
            response.sendRedirect(url);
            return;
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
